package com.dyna.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author zhoucaiwang
 */
@Configuration
public class DynaEsConfiguration {

    @Resource
    EsConfig esConfig;

    @Bean
    public RestHighLevelClient client() {
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(esConfig.getHost(), esConfig.getPort(), esConfig.getHttp()
                        )
                )
        );
        return restHighLevelClient;
    }

}
